package com.dongss.study.activemq.controller;

import com.dongss.study.activemq.entity.UserBean;
import com.dongss.study.activemq.mq.MessageSender;
import com.dongss.study.activemq.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * Created by dh on 2017/3/1.
 */
@Controller
@RequestMapping("/base")
public class HelloController {

    @Autowired
    UserService userService;

    @Resource
    MessageSender messageSender;

    @RequestMapping("test")
    public String testPage(){
        return "test";
    }

    @RequestMapping("sayHello")
    @ResponseBody
    public String sayHello(){
        System.out.println("sayHello called.");
        System.out.println(userService);
        return "hello,dongss.";
    }

    @RequestMapping("sayUserBean")
    @ResponseBody
    public UserBean sayUserBean(){
        UserBean userBean=new UserBean();
        userBean.setId(100);
        userBean.setName("dongshuan");
        userBean.setAge(20);
        return userBean;
    }

    @RequestMapping("testJMS")
    @ResponseBody
    public void testJMS(){

        messageSender.userLogin(100l,"dongssTest");
    }
}
